package com.syne.project.module.receiptdetail.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.syne.framework.aspectj.lang.annotation.Log;
import com.syne.framework.aspectj.lang.constant.BusinessType;
import com.syne.project.module.receiptdetail.domain.Receiptdetail;
import com.syne.project.module.receiptdetail.service.IReceiptdetailService;
import com.syne.framework.web.controller.BaseController;
import com.syne.framework.web.page.TableDataInfo;
import com.syne.framework.web.domain.AjaxResult;

/**
 * 收货明细 信息操作处理
 *
 * @author ruoyi
 * @date 2018-08-29
 */
@Controller
@RequestMapping("/module/receiptdetail")
public class ReceiptdetailController extends BaseController {
    private String prefix = "module/receiptdetail";

    @Autowired
    private IReceiptdetailService receiptdetailService;

    @RequiresPermissions("module:receiptdetail:view")
    @GetMapping()
    public String receiptdetail() {
        return prefix + "/receiptdetail";
    }

    /**
     * 查询收货明细列表
     */
    @RequiresPermissions("module:receiptdetail:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Receiptdetail receiptdetail) {
        startPage();
        List<Receiptdetail> list = receiptdetailService.selectReceiptdetailList(receiptdetail);
        return getDataTable(list);
    }

    /**
     * 新增收货明细
     */
    @GetMapping("/add")
    public String add() {
        return prefix + "/add";
    }

    /**
     * 新增保存收货明细
     */
    @RequiresPermissions("module:receiptdetail:add")
    @Log(title = "收货明细", action = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Receiptdetail receiptdetail) {
        return toAjax(receiptdetailService.insertReceiptdetail(receiptdetail));
    }

    /**
     * 修改收货明细
     */
    @GetMapping("/edit/{storerkey}")
    public String edit(@PathVariable("storerkey") String storerkey, ModelMap mmap) {
        Receiptdetail receiptdetail = receiptdetailService.selectReceiptdetailById(storerkey);
        mmap.put("receiptdetail", receiptdetail);
        return prefix + "/edit";
    }

    /**
     * 修改保存收货明细
     */
    @RequiresPermissions("module:receiptdetail:edit")
    @Log(title = "收货明细", action = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Receiptdetail receiptdetail) {
        return toAjax(receiptdetailService.updateReceiptdetail(receiptdetail));
    }

    /**
     * 删除收货明细
     */
    @RequiresPermissions("module:receiptdetail:remove")
    @Log(title = "收货明细", action = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(receiptdetailService.deleteReceiptdetailByIds(ids));
    }

}
